

    // 获取用户信息
package com.situ.controller;

import com.situ.bean.User;
import com.situ.service.IUserService;
import com.situ.service.impl.UserService;
import com.situ.util.SYS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

    @Controller
    @RequestMapping("users")
    public class UserController {
        @Autowired
         IUserService userService;
        // 根据id查询用户
        @RequestMapping( "getuser")
        @ResponseBody
        public User getUserById(@RequestParam("id") int id) {
            System.out.println("userService.getUserById(id)");
            return userService.getUserById(id);
        }

        // 添加用户
        @RequestMapping( "adduser")
        @ResponseBody
        public boolean addUser(User user) {
            System.out.println("userService.addUser(user)");
            return userService.addUser(user);
        }

        // 根据id删除用户
        @RequestMapping(value = "deleteuser")
        @ResponseBody
        public boolean deleteUserById(@RequestParam("id") int id) {
            System.out.println("userService.deleteUserById(id)");
            return userService.deleteUserById(id);
        }

        // 更新用户信息
        @RequestMapping(value = "updateuser")
        @ResponseBody
        public boolean updateUser(User user) {
            System.out.println("userService.updateUser(user)");
            return userService.updateUser(user);
        }

        // 查询所有用户
        @RequestMapping(value = "allusers")
        @ResponseBody
        public List<User> getAllUsers() {
            System.out.println("userService.getAllUsers()");
            return userService.getAllUsers();
        }







    }

